<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  .active {
    color: red;
  }
</style>
<body>
  <div id="app"></div>

  <template id="my-app">
    <!-- 对象语法: {'active': boolean} -->
    <div>哈哈哈</div>
    <!-- 默认与对象语法合并 -->
    <div class="aaa bbb" :class="{active : isActive}">呵呵呵</div>
    <button @click="toggle">变</button>
    <!-- 放到一个对象属性中 -->
    <div class="aaa bbb" :class="classObj">呵呵呵</div>
    <!-- 放到一个方法中 -->
    <div class="aaa bbb" :class="getClassObj()">呵呵呵</div>

  </template>
  <script src="../js/vue.js"></script>
  <script>
    const App = {
      template: '#my-app',
      data() {
        return {
          message: 'halo',
          isActive: true,
          classObj: {
            active : true,
            title: true
          }
        }
      },
      methods: {
        toggle() {
          this.isActive = !this.isActive
        },
        getClassObj() {
          return this.classObj
        }
      }
    }
    Vue.createApp(App).mount('#app')
  </script>
</body>
</html>